package server.datamodel;

import java.util.HashMap;

public class Team {

	private String name;
	private String ID;
	private HashMap<String, User> users = new HashMap<String, User>();
	
	public Team() {
		this.ID = Datamodel.generateID(this);
	}
	
	@Override
	public String toString() {
		return ID;
	}
	
	public void addUser(User user) {
		if(!users.containsKey(user.getID())) {
			users.put(user.getID(), user);
			user.setTeam(this);
		}
	}
	
	public void removeUser(User user) {
		if(users.remove(user.getID()) != null) {
			user.setTeam(null);
		}
	}
	
	public User getUser(String ID) {
		return users.get(ID);
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getID() {
		return ID;
	}
	
	public void setID(String iD) {
		ID = iD;
	}
	
}
